CLICKHOUSE_BACKUP_TAG = $(shell awk '$$0 ~ /^version:/ {print $$2}' Chart.yaml)

include ../../../scripts/common-envs.mk
include ../../../scripts/package.mk

generate:
	cozyvalues-gen -v values.yaml -s values.schema.json -r README.md
	../../../hack/update-crd.sh

image:
	docker buildx build images/clickhouse-backup \
		--tag $(REGISTRY)/clickhouse-backup:$(call settag,$(CLICKHOUSE_BACKUP_TAG)) \
		--cache-from type=registry,ref=$(REGISTRY)/clickhouse-backup:latest \
		--cache-to type=inline \
		--metadata-file images/clickhouse-backup.json \
		$(BUILDX_ARGS)
	echo "$(REGISTRY)/clickhouse-backup:$(call settag,$(CLICKHOUSE_BACKUP_TAG))@$$(yq e '."containerimage.digest"' images/clickhouse-backup.json -o json -r)" \
		> images/clickhouse-backup.tag
	rm -f images/clickhouse-backup.json
